Skip to content

Conversation

aaronsteers
Copy link
Contributor

@aaronsteers aaronsteers commented Jul 30, 2025

Replace MyPy with ty type checker (do not merge)

Summary

This PR replaces MyPy with ty (the new Rust-based Python type checker from astral-sh) across both PyAirbyte and airbyte-python-cdk repositories for performance and usability testing. This is an experimental change to evaluate ty as an alternative to MyPy.

Key changes:

  • Replace mypy dependency with ty ^0.0.1a16 in pyproject.toml
  • Remove MyPy configuration sections and add [tool.ty.src] configuration
  • Update CI workflows from mypy-check to ty-check
  • Create generic type-check poethepoet tasks using ty check commands
  • Remove mypy.ini configuration file (airbyte-python-cdk only)

Type checking results:

  • PyAirbyte: 108 type diagnostics found
  • airbyte-python-cdk: 205 type diagnostics found

Note: ty appears significantly stricter than MyPy, finding many more type issues.

Review & Testing Checklist for Human

  • Verify CI workflows execute successfully - Check that the ty-check jobs run without configuration errors (high error counts are expected for testing)
  • Test poethepoet tasks locally - Run poetry run poe type-check and poetry run poe check in both repositories to ensure tasks work correctly
  • Confirm ty installation works - Run poetry install in both repos to verify the ty dependency installs without conflicts
  • Validate configuration syntax - Review the [tool.ty.src] configuration sections are syntactically correct for ty (alpha tool, documentation may be incomplete)
  • Check developer workflow impact - Ensure this doesn't break IDE integrations or other development tools that rely on type checking

Recommended test plan:

  1. Pull both branches locally and run poetry install
  2. Execute poetry run ty check . (PyAirbyte) and poetry run ty check airbyte_cdk (airbyte-python-cdk)
  3. Run poethepoet tasks: poetry run poe type-check and main check tasks
  4. Monitor CI workflow execution in both repositories
  5. Compare performance/usability with MyPy baseline

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    subgraph PyAirbyte
        PA_pyproject["pyproject.toml<br/>(PyAirbyte)"]:::major-edit
        PA_workflow[".github/workflows/<br/>python_lint.yml<br/>(PyAirbyte)"]:::major-edit
        PA_lock["poetry.lock<br/>(PyAirbyte)"]:::minor-edit
    end
    
    subgraph airbyte-python-cdk  
        CDK_pyproject["pyproject.toml<br/>(airbyte-python-cdk)"]:::major-edit
        CDK_workflow[".github/workflows/<br/>python_lint.yml<br/>(airbyte-python-cdk)"]:::major-edit
        CDK_mypy["mypy.ini<br/>(airbyte-python-cdk)"]:::major-edit
    end
    
    subgraph Changes
        C1["Replace mypy → ty dependency"]
        C2["Update CI: mypy-check → ty-check"]  
        C3["Add [tool.ty.src] config"]
        C4["Update poethepoet tasks"]
    end
    
    PA_pyproject --> C1
    PA_pyproject --> C3
    PA_pyproject --> C4
    CDK_pyproject --> C1
    CDK_pyproject --> C3
    CDK_pyproject --> C4
    
    PA_workflow --> C2
    CDK_workflow --> C2
    CDK_mypy --> C3
    
    subgraph Legend
        L1[Major Edit]:::major-edit
        L2[Minor Edit]:::minor-edit  
        L3[Context/No Edit]:::context
    end

classDef major-edit fill:#90EE90
classDef minor-edit fill:#87CEEB
classDef context fill:#FFFFFF
Loading

Notes

  • Alpha software warning: ty v0.0.1a16 is alpha software and may have stability issues or breaking changes
  • No auto-noqa support: Unlike pyrefly, ty lacks CLI commands to automatically suppress existing type violations, making legacy code testing more challenging
  • Performance testing focus: This PR prioritizes evaluating ty's performance and usability over fixing existing type issues
  • Requested by: @aaronsteers
  • Devin session: https://app.devin.ai/sessions/89f33f9cbd9f48bda7165514bc3c1005

This is the first of two experimental PRs testing Rust-based Python type checkers. The second PR will test pyrefly (Meta/Facebook's type checker) for comparison.

Summary by CodeRabbit

  • Chores
    • Switched type checking tool from MyPy to Ty in development dependencies and automated workflows.
    • Updated type checking tasks and configuration to use Ty.
    • Removed all MyPy-related configuration and references.
    • Added Ty-specific configuration and tasks for type checking.

devin-ai-integration bot and others added 2 commits July 30, 2025 00:11
- Replace mypy dependency with ty ^0.0.1a16 in pyproject.toml
- Remove mypy configuration section and add ty.src configuration
- Update CI workflow from mypy-check to ty-check
- Create generic type-check Poe task using ty check command
- Update existing check task to use new type-check task
- Exclude tests, docs, and fixture directories from ty checking

This change enables testing of the new Rust-based ty type checker
as an alternative to mypy for performance and usability evaluation.

Co-Authored-By: AJ Steers <[email protected]>
Copy link
Contributor

Original prompt from AJ Steers:

@Devin - I'm wanting to put the two new rust Python typing libraries to the test. Create one PR to use ty and one PR to use pyre-something from meta.

Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

Testing This PyAirbyte Version

You can test this version of PyAirbyte using the following:

# Run PyAirbyte CLI from this branch:
uvx --from 'git+https://github.com/airbytehq/PyAirbyte.git@devin/1738195530-test-ty-type-checker' pyairbyte --help

# Install PyAirbyte from this branch for development:
pip install 'git+https://github.com/airbytehq/PyAirbyte.git@devin/1738195530-test-ty-type-checker'

Helpful Resources

PR Slash Commands

Airbyte Maintainers can execute the following slash commands on your PR:

  • /fix-pr - Fixes most formatting and linting issues
  • /poetry-lock - Updates poetry.lock file
  • /test-pr - Runs tests with the updated PyAirbyte

Community Support

Questions? Join the #pyairbyte channel in our Slack workspace.

📝 Edit this welcome message.

Copy link

github-actions bot commented Jul 30, 2025

PyTest Results (Fast Tests Only, No Creds)

256 tests  ±0   256 ✅ ±0   3m 26s ⏱️ +6s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit ce7e8b7. ± Comparison against base commit bfed5ef.

♻️ This comment has been updated with latest results.

Copy link
Contributor

coderabbitai bot commented Jul 30, 2025

📝 Walkthrough

Walkthrough

The Python project's type checking setup was migrated from MyPy to Ty. This involved updating the GitHub Actions workflow, replacing MyPy commands and configuration with Ty, and modifying the project's dependency and task definitions in pyproject.toml accordingly.

Changes

Cohort / File(s) Change Summary
GitHub Actions Workflow Update
.github/workflows/python_lint.yml
Renamed the type-check job and display name from MyPy to Ty, replaced the MyPy check step with a Ty check step, and added explicit read permissions for repository contents.
Type Checking Tool Migration
pyproject.toml
Removed MyPy dependency and configuration; added Ty dependency and configuration; updated tasks to use Ty instead of MyPy.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Would you like to also update any related documentation or developer onboarding instructions to reflect the switch from MyPy to Ty, wdyt?

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25d383f and 6e65602.

📒 Files selected for processing (1)
  • .github/workflows/python_lint.yml (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/python_lint.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Windows)
  • GitHub Check: Pytest (All, Python 3.11, Windows)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (No Creds)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1738195530-test-ty-type-checker

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (2)
pyproject.toml (1)

56-70: pytest-mypy still listed – will CI now error out?

With mypy gone, the pytest-mypy plugin (Line 69) will attempt to invoke a missing binary and fail the test phase.
Would it make sense to drop this dependency altogether or replace it with an equivalent pytest-ty (if/when one exists), so the pipeline stays green? wdyt?

.github/workflows/python_lint.yml (1)

59-81: Harden the new ty-check job with explicit permissions

CodeQL flags that the workflow doesn’t restrict the default GITHUB_TOKEN perms.
Shall we add the minimal read-only block for defence-in-depth? wdyt?

  ty-check:
    name: Ty Check
    permissions:
      contents: read        # minimal required
🧹 Nitpick comments (2)
pyproject.toml (2)

118-124: Excluding tests from type-checking – deliberate or accidental?

The new [tool.ty.src] block omits the entire tests tree. This mirrors many projects’ mypy setups, but it also hides type regressions inside our test code.
Should we narrow the ignore list to integration fixtures only and let unit tests stay in scope, or is the full exclusion desired for now? wdyt?


145-147: Poe task chain – consider surfacing Ty failures earlier?

check runs ruff, then ty, then a pytest collection. Given that ty currently emits 100+ diagnostics, would flipping the order to run poe type-check first shorten feedback for contributors?
Example:

-check = { shell = "ruff check . && poe type-check && pytest --collect-only -qq" }
+check = { shell = "poe type-check && ruff check . && pytest --collect-only -qq" }

Keeps the gate, but fails faster. Worth adopting? wdyt?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1266018 and a32151e.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • .github/workflows/python_lint.yml (2 hunks)
  • pyproject.toml (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: yohannj
PR: airbytehq/PyAirbyte#716
File: airbyte/logs.py:384-402
Timestamp: 2025-07-11T19:53:44.427Z
Learning: In the PyAirbyte project, when reviewing PRs, maintain clear separation of concerns. Don't suggest changes that are outside the scope of the PR's main objective, even if they would improve consistency or fix other issues. This helps with reviewing changes and potential reverts.
pyproject.toml (2)

Learnt from: aaronsteers
PR: #347
File: tests/integration_tests/fixtures/registry.json:48-48
Timestamp: 2024-10-08T15:34:31.026Z
Learning: Test fixtures in the PyAirbyte project do not need to align with real Docker repositories.

Learnt from: aaronsteers
PR: #347
File: tests/integration_tests/fixtures/registry.json:48-48
Timestamp: 2024-08-31T01:20:08.405Z
Learning: Test fixtures in the PyAirbyte project do not need to align with real Docker repositories.

🪛 GitHub Check: CodeQL
.github/workflows/python_lint.yml

[warning] 60-80: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Pytest (All, Python 3.11, Windows)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Windows)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (No Creds)
🔇 Additional comments (1)
pyproject.toml (1)

56-64: Pre-release ty pin looks good, but should it be an exact version?

ty is still in alpha (^0.0.1a16). Minor alpha bumps can introduce breaking changes.
Do we want to freeze to ==0.0.1a16 for deterministic CI while we evaluate, or is the caret-range intentional to track new alphas? wdyt?

Copy link

github-actions bot commented Jul 30, 2025

PyTest Results (Full)

318 tests  ±0   304 ✅ ±0   15m 47s ⏱️ -30s
  1 suites ±0    14 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit ce7e8b7. ± Comparison against base commit bfed5ef.

♻️ This comment has been updated with latest results.

aaronsteers and others added 2 commits July 30, 2025 21:54
…in permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant